package jdbcsh;

import java.io.IOException;

/**
 *
 * @author Dan Boitnott
 */
public abstract class BackslashCommand {
    private Interpreter interpreter;
    private Dispatcher dispatcher;
    private String cmd;
    private String usage;
    private String help;
    
    public void setInterpreter(Interpreter i) {
        interpreter = i;
    }
    
    public Interpreter getInterpreter() {
        return interpreter;
    }
    
    public void setDispatcher(Dispatcher d) {
        dispatcher = d;
    }
    
    public Dispatcher getDispatcher() {
        return dispatcher;
    }
    
    public Dispatcher dsp() {
        return getDispatcher();
    }
    
    public void setCmd(String cmd) {
        this.cmd = cmd;
    }        
    
    public String getCmd() {
        return cmd;
    }
    
    public void setUsage(String usage) {
        this.usage = usage;
    }
    
    public String getUsage() {
        return usage;
    }
    
    public void setHelp(String help) {
        this.help = help;
    }
    
    public String getHelp() {
        return help;
    }
    
    public void throwUsage() throws UsageException {
        throw new UsageException("\\" + getCmd() + " " + getUsage());
    }
    
    public abstract void run(String[] args) throws UsageException, IOException, 
            Dispatcher.DispatcherException;
}
